package day_2022_12_to_3.year2023;

/**
 * @author haomin
 * @date 2023/01/20 13:54
 **/
public class Day1_19_1_Num2299 {
    class Solution {
        public boolean strongPasswordCheckerII(String password) {
            if(password.length() < 8) return false;
            boolean hasSLetter = false, hasBLetter = false, hasDigit = false, hasSpecial = false;
            for(int i = 0; i < password.length(); ++i) {
                if(i != 0)
                    if(password.charAt(i) == password.charAt(i-1)) return false;
                char c = password.charAt(i);
                if(c >= 'a' && c <= 'z') hasSLetter = true;
                else if(c >= 'A' && c <= 'Z') hasBLetter = true;
                else if(Character.isDigit(c)) hasDigit = true;
                else if(new String("!@#$%^&*()-+").contains(c+"")) hasSpecial = true;
            }
            return hasSLetter && hasBLetter && hasDigit && hasSpecial;
        }
    }
}